<template>
    <div>
        <ul>
            <li v-for="item in result" @click="$router.push({path:'/main/detail',query:{id:item.s_id}})">
                {{item.title}}<br>
                {{item.con}}
            </li>
        </ul>
    </div>
</template>

<script>
import $api from '../../api/index'
export default {
    created(){
        console.log(this.$route.query.key);
        $api.search(this.$route.query.key).then(res => {
            console.log(res);
            if(res.code === 1){
                this.result = res.data;
            }
        })
    },
    data(){
        return {
            result:[]
        }
    }
}
</script>
